x=eval(input())
month=eval(input())
z=eval(input())
sum=0
for i in range(1,month):
    if x%400==0 or x%100!=0 and x%4==0:
        if i in (1,3,5,7,8,10,12):
            i=31
        elif i==2:
            i=29
        else:
            i=30
    else:
        if i in (1,3,5,7,8,10,12):
            i=31
        elif i==2:
            i=28
        else:
            i=30
    sum+=i
day=sum+z
print(day)
        

